package com.netintech.intelligenceInterface.iflytek.controller;

import com.netintech.intelligenceInterface.iflytek.domain.textLanguageDistinguish.TextLanguageDistinguishMultiParam;
import com.netintech.intelligenceInterface.iflytek.domain.textLanguageDistinguish.TextLanguageDistinguishSingleParam;
import com.netintech.intelligenceInterface.iflytek.util.RestTemplateUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import static com.netintech.intelligenceInterface.common.StaticBean.URL1;
import static com.netintech.intelligenceInterface.common.StaticBean.URL2;
import static com.netintech.intelligenceInterface.iflytek.domain.IFlyTekKey.API_KEY;
import static com.netintech.intelligenceInterface.iflytek.domain.IFlyTekKey.API_SECRET;

import java.util.Collections;
import java.util.Map;

/**
 * @author lining
 * @date 2021/4/27 16:45
 * 文本语种识别接口
 */
@RestController
public class TextLanguageDistinguishController {

    /**
     * 单文本语种识别接口
     */
    private static final String SINGLE_TEXT_LANGUAGE_DISTINGUISH_URL = "/tuling/ltr/v2/process";

    /**
     * 多文本语种识别接口
     */
    private static final String MULTI_TEXT_LANGUAGE_DISTINGUISH_URL = "/tuling/ltr/v2/multi";

    @PostMapping("singleTextLanguageDistinguish")
    public String singleTextLanguageDistinguish(@RequestBody TextLanguageDistinguishSingleParam param) {
        String url = URL1 + SINGLE_TEXT_LANGUAGE_DISTINGUISH_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/test/singleTextLanguageDistinguish")
    public String singleTextLanguageDistinguishTest(@RequestBody TextLanguageDistinguishSingleParam param) {
        String url = URL1 + SINGLE_TEXT_LANGUAGE_DISTINGUISH_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("multiTextLanguageDistinguish")
    public String multiTextLanguageDistinguish(TextLanguageDistinguishMultiParam param) {
        String url = URL1 + MULTI_TEXT_LANGUAGE_DISTINGUISH_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/test/multiTextLanguageDistinguish")
    public String multiTextLanguageDistinguishTest(TextLanguageDistinguishMultiParam param) {
        String url = URL1 + MULTI_TEXT_LANGUAGE_DISTINGUISH_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }
}
